Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error upon stopping recording. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexthewilde
Copy link

@alexthewilde alexthewilde commented Jul 6, 2016

Prevents occasional error message upon stopping recording.

Copy link

@no-chris no-chris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is the right way to fix this. Sure it works, but the record() method is still called although it shouldn't, given that finish() have been called before.

I'm not using WebAudioRecorder.js (only the workers) so I cannot check this but cancelling the onaudioprocess callback before sending the finish command to the worker might do the trick.

this.processor.onaudioprocess = null; // <= add this
this.processor.disconnect();
delete this.processor;
this.worker.postMessage({ command: "finish" });

@@ -39,7 +39,7 @@ function record(buffer) {
if (bufferCount++ < maxBuffers)
if (encoder)
encoder.encode(buffer);
else
else if (recBuffers)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is wrong. You need to wrap the top level condition with brackets otherwise you will trigger a timeout with the following else.

    if (bufferCount++ < maxBuffers) {
        if (encoder)
            encoder.encode(buffer);
        else if (recBuffers)
            recBuffers.push(buffer);
    } else
        self.postMessage({ command: "timeout" });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants